package com.cc.user.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cc.common.utils.R;
import com.cc.common.utils.ResponseData;
import com.cc.common.utils.ResultMsg;
import com.cc.user.entity.ServicerEntity;
import com.cc.user.service.ServicerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



@RestController
@RequestMapping("user/servicer")
@Api(tags="客服")
public class ServicerController {
    @Autowired
    private ServicerService servicerService;


    @GetMapping("/getServicer")
    @ApiOperation("获取客服信息")
    public ResponseData<ServicerEntity> getServicer() {
        ServicerEntity servicer = servicerService.getOne(new QueryWrapper<ServicerEntity>());
        return ResponseData.success(servicer);
    }

    @PostMapping("/addServicer")
    @ApiOperation("添加客服信息")
    public ResponseData addServicer(ServicerEntity servicerEntity) {
        servicerService.save(servicerEntity);
        return ResponseData.success("添加成功",true);
    }

    @PostMapping("/updateServicer")
    @ApiOperation("更新客服信息")
    public ResponseData updateServicer(ServicerEntity servicerEntity) {
        boolean flag = servicerService.updateById(servicerEntity);
        if(!flag)   return ResponseData.success("更新失败",false);
        return ResponseData.success("更新成功",true);
    }
//    /**
//     * 列表
//     */
//
//
//    /**
//     * 信息
//     */
//    @RequestMapping("/info/{id}")
//    //@RequiresPermissions("user:servicer:info")
//    public R info(@PathVariable("id") Long id){
//		ServicerEntity servicer = servicerService.getById(id);
//
//        return R.ok().put("servicer", servicer);
//    }
//
//    /**
//     * 保存
//     */
//    @RequestMapping("/save")
//    //@RequiresPermissions("user:servicer:save")
//    public R save(@RequestBody ServicerEntity servicer){
//		servicerService.save(servicer);
//
//        return R.ok();
//    }
//
//    /**
//     * 修改
//     */
//    @RequestMapping("/update")
//    //@RequiresPermissions("user:servicer:update")
//    public R update(@RequestBody ServicerEntity servicer){
//		servicerService.updateById(servicer);
//
//        return R.ok();
//    }
//
//    /**
//     * 删除
//     */
//    @RequestMapping("/delete")
//    //@RequiresPermissions("user:servicer:delete")
//    public R delete(@RequestBody Long[] ids){
//		servicerService.removeByIds(Arrays.asList(ids));
//
//        return R.ok();
//    }

}
